package com.littlec.sdk.utils;

import java.util.List;

import com.cmcc.groupcontacts.MainApp;
import com.littlec.sdk.entity.EnumLoginStatus;
import com.yinhai.model.ContactsUser;
import com.yinhai.service.ContactUserServiceImpl;

public class CMChatGlobalStorage {
	private static final String TAG = "CMChatGlobalStorage";
	public static String MTC_LOG_PATH;
	public static String MTC_CRASH_LOG_PATH;
	public static String MTC_PROFILE_PATH;
	public static String MTC_DATA_PATH;
	public static String MTC_DATA_EMAIL_PATH;
	public static String MTC_DOWNLOAD_PATH;
	public static String MTC_DOWNLOAD_APP_UPDATE_PATH;
	public static String MTC_DOWNLOAD_THUMBNAIL_SMALL_PATH;
	public static String MTC_DOWNLOAD_THUMBNAIL_MIDDLE_PATH;

	private static CMChatGlobalStorage mGlobalInstance = null;
	private EnumLoginStatus mLoginStatus = EnumLoginStatus.STATE_NONE;
	private String mLoginUserName = "15025443417";
	private String mLoginPassWord = "123456";
	private String mLoginUserRealName = "";

	public String getmLoginUserRealName() {
		
		if(mLoginUserRealName == null || "".equals(mLoginUserRealName)) {
			ContactUserServiceImpl contactUserService =  new ContactUserServiceImpl(MainApp.getContext());
			List<ContactsUser>  users = contactUserService.findContactUserByLoginName(mLoginUserName);
			if(users != null && users.size() > 0) {
				mLoginUserRealName = users.get(0).getName() == null?"":users.get(0).getName();
			}
		}
		
		return mLoginUserRealName;
	}

	public void setmLoginUserRealName(String mLoginUserRealName) {
		this.mLoginUserRealName = mLoginUserRealName;
	}

	public static CMChatGlobalStorage getInstance() {
		if (mGlobalInstance == null) {
			synchronized (CMChatGlobalStorage.class) {
				if (mGlobalInstance == null) {
					mGlobalInstance = new CMChatGlobalStorage();
				}
			}
		}
		return mGlobalInstance;
	}

	public void setLoginStatus(EnumLoginStatus loginStatus) {
		this.mLoginStatus = loginStatus;
	}

	public EnumLoginStatus getLoginStatus() {
		return this.mLoginStatus;
	}

	public void destory() {
		clearUser();

		this.mLoginStatus = EnumLoginStatus.STATE_NONE;
		mGlobalInstance = null;
	}

	public void setLoginUserName(String loginUserName) {
		this.mLoginUserName = loginUserName;
	}

	public void setLoginPassWord(String loginPassWord) {
		this.mLoginPassWord = loginPassWord;
	}

	public String getmLoginPassWord() {
		return mLoginPassWord;
	}

	public String getmLoginUserName() {
		return mLoginUserName;
	}

	public void setmLoginUserName(String mLoginUserName) {
		this.mLoginUserName = mLoginUserName;
	}

	public void setmLoginPassWord(String mLoginPassWord) {
		this.mLoginPassWord = mLoginPassWord;
	}

	private void clearUser() {
		this.mLoginPassWord = "";
		this.mLoginUserName = "";
	}
	
	
}
